import './item.html';
import { Template } from 'meteor/templating';

Template.post_item.onRendered(function(){
	$('.post-item').hover(function(){
		$(this).css({'background-color': 'rgba(189, 192, 168, 0.75)',
			"cursor": "pointer"});
	}, function(){
		$(this).css('background-color', '#ffffff');
	});


});

Template.post_item.helpers({

	image(){
		return 'https://uploadbeta.com/api/pictures/random/?key=Computing';
	},
	title(){

		return this.title;
	},
	date(){
		let date = moment(this.createAt).format('YYYY年MMMMDD日, HH:mm:ss');
		return date;
	},
	author() {
		return this.author;
	}

});

Template.post_item.events({
	"click .post-item"(event, instance){
		event.preventDefault();
    event.stopPropagation();
		Session.set('one-post-show', this);
		$('.post-modal').modal('show');
	}
});
